{% extends "base.html" %}

{% block title %}注册 - 万岛潜水{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-6">
            <div class="card shadow-sm my-5">
                <div class="card-body">
                    <h1 class="card-title text-center mb-4">用户注册</h1>
                    
                    {% with messages = get_flashed_messages() %}
                    {% if messages %}
                    <div class="alert alert-danger">
                        {% for message in messages %}
                        {{ message }}
                        {% endfor %}
                    </div>
                    {% endif %}
                    {% endwith %}
                    
                    <form method="post" action="{{ url_for('main.register') }}">
                        {{ form.hidden_tag() }}
                        <div class="mb-3">
                            {{ form.username.label(class="form-label") }}
                            {{ form.username(class="form-control", placeholder="请输入用户名") }}
                            {% for error in form.username.errors %}
                            <div class="text-danger">{{ error }}</div>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.email.label(class="form-label") }}
                            {{ form.email(class="form-control", placeholder="请输入邮箱") }}
                            {% for error in form.email.errors %}
                            <div class="text-danger">{{ error }}</div>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.phone.label(class="form-label") }}
                            {{ form.phone(class="form-control", placeholder="请输入手机号") }}
                            {% for error in form.phone.errors %}
                            <div class="text-danger">{{ error }}</div>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.password.label(class="form-label") }}
                            {{ form.password(class="form-control", placeholder="请输入密码") }}
                            {% for error in form.password.errors %}
                            <div class="text-danger">{{ error }}</div>
                            {% endfor %}
                        </div>
                        <div class="mb-3">
                            {{ form.password2.label(class="form-label") }}
                            {{ form.password2(class="form-control", placeholder="请再次输入密码") }}
                            {% for error in form.password2.errors %}
                            <div class="text-danger">{{ error }}</div>
                            {% endfor %}
                        </div>
                        <div class="d-grid gap-2">
                            {{ form.submit(class="btn btn-primary") }}
                        </div>
                    </form>
                    
                    <div class="text-center mt-3">
                        <p>已有账号？<a href="{{ url_for('main.login') }}">立即登录</a></p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %} 